#!/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time: 2020/3/17  14:03
# @Author: 余浪人
# @email: yulangren520@gmail.com
from datetime import datetime
from apps.models import BaseModel,db


class TL_User_Model(BaseModel):
    username = db.Column(db.String(64),comment='登录名')
    password = db.Column(db.String(256),comment='密码')
    user_email = db.Column(db.String(64),comment='邮箱')
    user_integral = db.Column(db.Integer,default=0,comment='积分')
    user_qq = db.Column(db.String(64), comment='qq')
    user_nickname = db.Column(db.String(64), comment='昵称')
    user_phone = db.Column(db.String(11), comment='电话')
    user_gender = db.Column(db.Integer, comment='性别')
    remark = db.Column(db.String(512), comment='备注')
    content_jurisdiction = db.Column(db.Integer,default=0, comment='文章权限')
    comment_jurisdiction = db.Column(db.Integer,default=0, comment='评论权限')
    user_logins= db.Column(db.Integer,default=0,comment='登录次数')
    new_login_time = db.Column(db.DateTime,default=datetime.now(),comment='最近登录时间')
    def __repr__(self):
        return f'用户：<{self.username}>'
    def keys(self):
        return 'username','password','user_email','user_integral','user_qq','user_nickname','user_phone','user_gender','remark','jurisdiction','new_login_time','status','user_logins'



class TL_Grade_Model(BaseModel):
    grade_name = db.Column(db.String(64),default=None,comment='等级名称')
    grade_integral = db.Column(db.Integer,default=0,comment='等级积分')
    def __repr__(self):
        return f'积分等级：<{self.grade_name}>'

    def keys(self):
        return 'grade_name','grade_integral'